
<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="renderer" content="webkit"> 
	<meta content="always" name="referrer">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>酒店详情页</title>
    <!--[if lt IE 9]>
			<script type="text/javascript">
				window.location.href = "tip.html"
			</script>
		<![endif]-->
    <link rel="stylesheet" href="css/layui.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/info.css">
		
    <!--[if IE 8]>
		<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
	<![endif]-->

    <script src="js/jquery.min.js"></script>
    <script src="js/wang.js"></script>
	<script src="lib/layui/layui.js"></script>
	<script src="js/ajaxSet.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .header{height: 42px;line-height: 42px;background: #FFFFFF;font-size:12px;border-bottom:1px solid #ffd7c0}
        .header .w_1190{position: relative;width: 1190px;margin: 0 auto;}
        .header .w_1190 .h_left b{position: absolute; top:50%; margin-top: -9px; margin-right: 5px; width: 20px;height: 16px; }
        .header .w_1190 .h_left b ul{position: absolute}
        .header .w_1190 .bhover{min-width: 200px;z-index:9999; height: 70px; background-color: #fff;position: absolute; top: 20px; left: -45px; border-radius: 4px;padding: 10px;box-shadow: 0 0 5px #f1f1f1;}
        .header .w_1190 .bhover span:last-child{color: #f40;font-size: 21px;font-weight: 700; margin:0 3px;}
        .header .w_1190 .bhover li{height: 22px;line-height: 22px;}
        .header .h_left a.c_01afff {color: #ff6002;margin-right:60px;}
        .header .h_right a {margin-left: 40px;color: #4a4a4a;}
        .layui-tab-item{
        	min-height: 100px;
        }
        #notes{
        	border-bottom:  1px solid #ccc;
        }
        .detailed .layui-tab .layui-tab-content .room .moneylist ul{
        	top: 50px;
        }
        .detailed .layui-tab .layui-tab-content .room .moneylist .offset{
        	top: 0;
        }
		#userName{
			float: left;
			width: 75px;
			text-align: center;
			position: relative;
			cursor: pointer;
			display: none;
		}
		#userName li:after{
			display:block;content:"";visibility:hidden;height:0;
			border-bottom:  1px solid #000000;
		}
		#userName dl{
			top: 42px;
			width: 100%;
			position: absolute;
			display: none;
			background: #fff;
			z-index: 9999;
		}
		#cm .active {
			background: rgb(65, 137, 252); 
		}
		#cal {
		    width: 434px;
		    border: 1px solid #c3d9ff;
		    font-size: 12px;
		    /*margin: 8px 0 0 15px*/	
		}
		#cal #top {
		    height: 29px;
		    line-height: 20px;
		    background: #e7eef8;
		    color: #003784;
		    padding-left: 70px
		}
		#cal #top i{
		    font-size: 26px;
		    position: relative;
		    top: 5px;
		}
		#cal #top select {
		    font-size: 12px
		}
		#cal #top input {
		    padding: 0
		}
		#cal ul#wk {
		    margin: 0;
		    padding: 0;
		    height: 25px
		}
		#cal ul#wk li {
		    float: left;
		    width: 57px;
		    text-align: center;
		    line-height: 25px;
		    list-style: none
		}
		#cal ul#wk li b {
		    font-weight: normal;
		    color: #c60b02
		}
		#cal #cm {
		    clear: left;
		    border-top: 1px solid #ddd;
		    border-bottom: 1px dotted #ddd;
		    position: relative
		}
		#cal #cm .cell {
		    position: absolute;
		    width: 42px;
		    height: 36px;
		    text-align: center;
		    margin: 0 0 0 9px
		}
		#cal #cm .cell .so {
		    font: bold 16px arial;
		}
		#cal #bm {
		    text-align: right;
		    height: 24px;
		    line-height: 24px;
		    padding: 0 13px 0 0
		}
		#cal #bm a {
		    color: 7977ce
		}
		#cal #fd {
		    display: none;
		    position: absolute;
		    border: 1px solid #dddddf;
		    background: #feffcd;
		    padding: 10px;
		    line-height: 21px;
		    width: 150px
		}
		#cal #fd b {
		    font-weight: normal;
		    color: #c60a00
		}
		.detailCont{
		    font-size: 12px;
		    width: 150px;
		    overflow: hidden;
		    float: left;
		    margin-left: 20px;
		    text-overflow: ellipsis;
		    white-space: nowrap;
		}
	</style>
</head>
<body>
    <div class="header">
	<div class="w_1190">
		<div class="h_right fr">
			<a href="index.html">YIXA首页</a>
			<a href="dingdan.html">我的订单</a>
			<a href="zhanghu.html">账户设置</a>
			<a href="about.html">关于我们</a>
		</div>
		<div class="h_left">
			<ul id="userName">
				<li></li>
				<dl>
					<dd>退出登录</dd>
				</dl>
			</ul>
			<!-- 未登录 -->
				<a href="login.html" class="c_01afff" id="login">登录</a>
				<a href="register.html" class="registerno">免费注册</a>
			<!-- 已登录 -->
		</div>
	</div>
</div>

<script type="text/javascript">
	
	$("#userName").on("click",function(){
	    $(this).find("dl").slideToggle(200)
	})
	
	$("#userName dd").on("click",function(){
	    $.ajax({
	    	type:"post",
	    	url:"http://52lvu.cn:8080/api/login/logout",
	        data:{
	            userId : token.userId
	        },success : function (result){

	            
	            if (result.resultCode == 200) {
	            	localStorage.removeItem("token");
	            	window.location.href="login.html"
	            }
	        },error : function (e){
	            layer.msg("请求错误！请稍候重试",{icon:2,time:3000});
	        }
	    });
	})
	
	var token = JSON.parse(localStorage.getItem('token'));
	
	if (token) {
		var expiredTime = 1800000;
		var loginTime = token.loginTime
		var nowTime = new Date().getTime();

		
		if ( (nowTime - loginTime) > expiredTime ) {
			localStorage.removeItem("token");
			window.location.href = "login.html";
		}else{
			$("#userName").show(); 
			$(".registerno").hide();
			$("#login").hide()
			$("#userName li").html(token.userName)
		}
	}else{
	    window.location.href="login.html";
	}
	
</script>
	<div class="search-list"></div>

    <div class="hotel w-1200">
        <div class="title">
            <a href="index.html" class="active">首页></a>
            <a href="javascript:void(0)" onclick="location.reload()" id="mbx"> </a>
        </div>
        <div class="list clearfloat">
            <ul class="fl">
                <li class="fn-18" id="name"></li>
                <li class="fn-16" id="address"></li>
            </ul>
            <ul class="fr">
            </ul>
        </div>
        <div class="container clearfloat">
            <div class="cont-left">
            	<div class="lunbo">
            		<div class="layui-carousel" id="test1">
			  			<div carousel-item id="bannerList">
			    
			  			</div>
					</div>
            	</div>
            </div>
        </div>
    </div>
    
    <div class="table-box w-1200">
    	<table cellpadding="0" cellspacing="0" id="1" class="mt-20 w_100">
			<tr>
				<td>
	                <div id="cal" style="width: 100%;">
			       		<div id="top" id="date-left">
			       			<i class="layui-icon" id="date-left">&#xe603;</i>   
			       			公元 <select id="YYY"></select>
			       			年  <select id="MMM"></select> 
			       			 月 农历<span></span>
			       			 年[ <span></span>年 ] 
			       			<input type="button" value="回到今天" title="点击后跳转回今天" style="padding: 0px">
			       			<i class="layui-icon" id="date-right">&#xe602;</i>   
			       		</div>
				        <ul id="wk">
				            <li>一</li>
				            <li>二</li>
				            <li>三</li>
				            <li>四</li>
				            <li>五</li>
				            <li><b>六</b></li>
				            <li><b>日</b></li>
				            <li>一</li>
				            <li>二</li>
				            <li>三</li>
				            <li>四</li>
				            <li>五</li>
				            <li><b>六</b></li>
				            <li><b>日</b></li>
				            <li>一</li>
				            <li>二</li>
				            <li>三</li>
				            <li>四</li>
				            <li>五</li>
				            <li><b>六</b></li>
				            <li><b>日</b></li>
				        </ul>
				        <div id="cm"></div>
				        <div id="bm"></div>
		        	</div>
	        	</td>
		    </tr>
		</table>
    </div>
    
    <div class="detailed w-1200">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">酒店房型</li>
                <li>酒店信息</li>
                <li>预定须知</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show room">
                    <div class="search">
                        <div class="bar clearfloat">
                            <div class="come">入住</div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="come1" value="2018-03-02" >
                                </div>
                            </div>
                            <div style="float: left;margin-left: 10px;line-height: 34px">…</div>
                            <div style="float: left;margin-left: 10px;">离店</div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="level1" value="2018-03-02">
                                </div>
                            </div>
                            <div class="timer">共<span id="data">1</span>天</div>
                        </div>
                    </div>
                    <div class="head-tit">
                    	<ul class="clearfloat">
                            <li style="background: #ff6002;color: #fff;">客房类型</li>
                            <li>适合人数</li>
                            <li>价格</li>
                            <li>客房&人数</li>
                            <li style="border-bottom: 1px solid #d2d2d2;">立刻购买</li>
                        </ul>
                    </div>
                    <div class="content" style="min-height: 211px;">
                       	<div class="roomlist" id="roomCont">
                       		
                       	</div>
                       	<div class="moneylist">
                       		<ul>
                       			<li id="price1"></li>
                       			<li class="book">添加预定</li>
                       			<li class="inpmont fn-14">重要说明：不退换</li>
                       		</ul>
                       	</div>
                    </div>
                </div>
                <div class="layui-tab-item" id="introduce"></div>
                <div class="layui-tab-item" id="notes"></div>
            </div>
        </div>
    </div>

<div id="footer"></div>
<div id="qq">
	
</div>
</body>
</html>
<script id="roomListCont" type="text/html">
	{{#  layui.each(d, function(index, item){ }}
	<div class="lift" data-childPrice = "{{#  if(item.childPrice){ }}{{item.childPrice}}{{#  } }}" data-childBedPrice = "{{#  if(item.childBedPrice){ }}{{item.childBedPrice}}{{#  } }}" data-addBedPrice = "{{#  if(item.addBedPrice){ }}{{item.addBedPrice}}{{#  } }}" data-singlePrice = "{{#  if(item.singlePrice){ }}{{item.singlePrice}}{{#  } }}" data-roomId = "{{#  if(item.id){ }}{{item.id}}{{#  } }}" data-roomMoney="{{#  if(item.price){ }}{{item.price}}{{#  } }}">
    	<a class="toggle"></a>
    	<ul class="clearfloat fn-16">
            <li class="list1 list11 toggyl">
                <p class="fl">{{#  if(item.type){ }}{{item.type}}{{#  } }}</p>
                <p class="fr">仅剩 
            		<span>
	            		{{#  if(item.remain){ }}
							{{item.remain}}
						{{#  } else { }}
							0
						{{#  } }} 
               		</span> 间客房
                </p>
                <p class="detailCont">
            		
                </p>
                <div class="detailHide" style="display: none;">
                	{{#  if(item.detail){ }}
						{{item.detail}}
					{{#  } }} 
                </div>
            </li>
            <li>
                <img src="img/renshu.png" alt="">
                <img src="img/renshu.png" alt="">
            </li>
            <li style="color:#80ce84;" class="ddprice"></li>
            <li class="chooseRoom">
                <div class="layui-form clearfloat">
                    <div class="layui-form-item select">
                        <div class="layui-input-block roomNum">
                            <select name="interest1" lay-filter="test{{index}}">
                            	<option value="0" selected="">0</option>
                            	{{# for(var i = 1, len = item.remain+1 ; i < len; i++){ }}
	                                <option value="{{i}}" >{{i}}</option>
                                {{# } }}
                            </select>
                            <i class="desc"><laber for="interest1">间房</laber></i>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="clearfloat fn-16 hidelist">
            <li class="list2">
                <p class="fl">床型</p>
                <p class="fr isBigBad">
                	<input type="radio" name="oneortwo{{index}}"  value="1"  checked="checked"/>1张双人床
                	<input type="radio" name="oneortwo{{index}}"  value="0"  />2张单人床
                </p>
            </li>
            <li></li>
            <li style="color:#80ce84;"></li>
            <li></li>
        </ul>
        <ul class="clearfloat fn-16 hidelist">
            <li class="list1 list11">
                <p class="fl">成人</p>
                <p class="fr"></p>
            </li>
            <li></li>
            <li style="color:#80ce84;" class="ddprice">{{#  if(item.price){ }}{{item.price}}{{#  } }}</li>
            <li class="chooseRoom">
                <div class="layui-form clearfloat">
                    <div class="layui-form-item select">
                        <div class="layui-input-block peopleNum">
                            <select name="interest1" lay-filter="test{{index}}">
                            	<option value="0" selected="">0</option>
                            	{{# for(var i = 1, len = (item.remain*2)+1 ; i < len; i++){ }}
	                                <option value="{{i}}">{{i}}</option>
                                {{# } }}
                            </select>
                            <i class="desc"><laber for="interest1">人数</laber></i>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="clearfloat fn-16 hidelist">
            <li class="list1">
                <p class="fl">儿童是否占床</p>
                <p class="fr childbad" style="color: #000000;background: none;">
                	<input type="radio" name="aasd{{index}}" />占床
                	<input type="radio" name="aasd{{index}}" checked="checked" />不占床
                </p>
            </li>
            <li></li>
            <li style="color:#80ce84;font-size: 12px;line-height: 16px;" class="ddprice">
            	占床价：{{#  if(item.childBedPrice){ }}{{item.childBedPrice}}{{#  } }}<br />
            	不占床：{{#  if(item.childPrice){ }}{{item.childPrice}}{{#  } }}
            </li>
            <li class="chooseRoom">
                <div class="layui-form clearfloat">
                    <div class="layui-form-item select">
                        <div class="layui-input-block childNum">
                            <select name="interest1" lay-filter="test{{index}}" class="childNum">
                            	<option value="0" selected="">0</option>
                            	{{# for(var i = 1, len = item.remain+1 ; i < len; i++){ }}
	                                <option value="{{i}}" >{{i}}</option>
                                {{# } }}
                            </select>
                            <i class="desc"><laber for="interest1">人数</laber></i>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="clearfloat fn-16 hidelist">
            <li class="list1">
                <p class="fl">是否加床</p>
                <p class="fr"></p>
            </li>
            <li></li>
            <li style="color:#80ce84;" class="addBedNum">{{#  if(item.addBedPrice){ }}{{item.addBedPrice}}{{#  } }}</li>
            <li class="chooseRoom">
                <div class="layui-form clearfloat">
                    <div class="layui-form-item select">
                        <div class="layui-input-block addBad">
                            <select name="interest1" lay-filter="test{{index}}">
                            	{{# for(var i = 0, len = item.remain+1 ; i < len; i++){ }}
	                                <option value="{{i}}" >{{i}}</option>
                                {{# } }}
                            </select>
                            <i class="desc"><laber for="interest1">人数</laber></i>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="clearfloat fn-16 hidelist">
            <li class="list1">
                <p class="fl">单房差</p>
            </li>
            <li></li>
            <li style="color:#80ce84;" class="ddprice">{{#  if(item.singlePrice){ }}{{item.singlePrice}}{{#  } }}</li>
            <li>
            	<div class="layui-form clearfloat">
                    <div class="layui-form-item select">
                        <div class="layui-input-block difference">
                            <select name="interest1" lay-filter="test{{index}}">
                            	{{# for(var i = 0, len = item.remain+1 ; i < len; i++){ }}
	                                <option value="{{i}}" >{{i}}</option>
                                {{# } }}
                            </select>
                            <i class="desc"><laber for="interest1">人数</laber></i>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
{{# }); }}
</script>
<script>
	
    layui.use(['form', 'layedit', 'laydate','laytpl','element','carousel'], function() {
        var form = layui.form
            , layer = layui.layer
            , element = layui.element
            , layedit = layui.layedit
            , laydate = layui.laydate
            , laytpl = layui.laytpl
            , carousel = layui.carousel;;
		 $("#qq").load("lib/qq.html");$("#footer").load("lib/footer.html");
		var token = localStorage.getItem("token");
		
		function getCountDays() {
	        var curDate = new Date();
	        var curMonth = curDate.getMonth();
	        curDate.setMonth(curMonth + 1);
	        curDate.setDate(0);
	        return curDate.getDate();
		}

		if(token){
			
		}else{
			window.location.href='index.html'
		}
		
		$("#come1").val(wang.getData())
		$("#level1").val(wang.getData(0,0,1))

        laydate.render({
            elem: '#comedata',
            theme: '#ff660c'
        });
        laydate.render({
            elem: '#leveldata',
            theme: '#ff660c'
        });
        
        laydate.render({
            elem: '#come1',
            theme: '#ff660c',
            min : wang.getData(),
            done: function(value, date, endDate){

				var startTime = new Date($("#come1").val()),
            		endTime = new Date($("#level1").val());
		    	$("#level1").val();
		    	
		    	var end = new Date(startTime);
		    	end.setDate(end.getDate()+1);  

		    	
		    	
		    	var days = parseInt(endTime - startTime) / 1000 / 60 / 60 / 24;
				
				$("#data").html(days);
				
				calculate();
				
			}
        });
        
        laydate.render({
            elem: '#level1',
            theme: '#ff660c',
            min : wang.getData(0,0,1),
            done: function(value, date, endDate){
            	var startTime = new Date($("#come1").val()),
            		endTime = new Date($("#level1").val());
		    	var days = parseInt(endTime - startTime) / 1000 / 60 / 60 / 24;
				$("#data").html(days)
				calculate();
			}
            
        });

        // 酒店信息
        $.ajax({
	        type:"post",
	        url:"http://52lvu.cn:8080/api/hotel/getHotel",
	        data :{
	        	id : wang.getQueryString("id")
	        },
	        success : function (result){

	            if (result.data) {
	            	var data = result.data;
		            
		            try{
		            	$("title").html(data.name)
		            }catch(e){
		            	document.title=data.name;
		            }
		    		$("#name").html(data.name);
		    		$("#mbx").html(data.name);
		    		$("#address").html(data.address);
		        	$("#introduce").html(data.introduce);
		        	
		        	$("#introduce img").attr("title","")
		        	
		        	$("#notes").html(data.notes);
		        	var picList = data.picture.split(";");
//		        	
		        	for ( i = 0 ; i < picList.length-1 ; i++) {
		        		$("#bannerList").append("<div><a href='javascript:;'><img src='http://52lvu.cn:8080/hotel/upload"+picList[i]+"' /></a></div>")
		        	}

		        	carousel.render({
					    elem: '#test1'
					    ,width: '100%' //设置容器宽度
					    ,height:"100%"
					    ,arrow: 'always' //始终显示箭头
					    ,anim: 'default' //切换动画方式
					    ,interval : '5000'
					  });
				  	for ( i = 0 ; i < picList.length-1 ; i++) {
				  		$("#test1 li").eq(i).append("<img src='http://52lvu.cn:8080/hotel/upload"+picList[i]+"' />")
	        		}
	            }
	            
	        },error : function (e){
	            layer.msg("请求错误！请稍候重试",{icon:2,time:3000});
	        }
	        
	    });	
	    
	    //房间列表
	    $.ajax({
	        type:"post",
	        url:"http://52lvu.cn:8080/api/room/findAllByHotelId",
	        data :{
	        	hotelId : wang.getQueryString("id")
	        },
	        success : function (result){
	    		
				var roomList = roomListCont.innerHTML;
				var data = result.data;
			
				if (data.length < 1) {
					$("#roomCont").html("<center style='font-size: 30px;margin-top: 200px;'>请求的酒店暂无房型</center>")
					layer.msg("请求的酒店暂无房型",{icon:2,time:3000});
					setTimeout(function(){
					    window.location.href='index.html';
					},2000)
				}else{
					laytpl(roomList).render(data, function(html){	
						$("#roomCont").html(html);
						form.render();
					});
					
					for ( i = 0 ; i < $(".detailCont").length ; i++) {
						var rep = wang.filterStr($(".detailHide").eq(i).html(),"html")
						$(".detailCont").eq(i).html(rep).attr("title",rep)
					}
					
					
				}
				
				$("#roomCont .roomNum dd").on("click",function(){
					$(this).parents(".lift").attr({"data-roomNum":$(this).html()})
					calculate()
				})
	            $("#roomCont .childNum dd").on("click",function(){
					$(this).parents(".lift").attr({"data-childNum":$(this).html()})
					calculate()
				})
	            $("#roomCont .addBad dd").on("click",function(){
					$(this).parents(".lift").attr({"data-addBad":$(this).html()})
					calculate()
				})
				 $("#roomCont .difference dd").on("click",function(){
					$(this).parents(".lift").attr({"data-difference":$(this).html()})
					calculate()
				})
				 $("#roomCont .peopleNum dd").on("click",function(){
					$(this).parents(".lift").attr({"data-peopleNum":$(this).html()})
					calculate()
				})
	            
	            $("#roomCont .isBigBad input").on("click",function(){
	                $(this).parents(".lift").attr({"data-isBigBad":$(this).val()})
	            })
	            
	            $(".childbad input").on("click",function(){
					if ($(this).index() == 0) {
						$(this).parents(".lift").attr({"data-isbad":1})
					} else{
						$(this).parents(".lift").attr({"data-isbad":0})
					}	             
					calculate();
	            })
	            
	            $(".toggle").on("click",function(){
	                $(this).parents(".lift").find(".hidelist").toggle();
	                $(this).toggleClass("active");
	            })
	            
	            $(".toggyl").on("click",function(){
	                $(this).parents(".lift").find(".hidelist").toggle();
	                $(this).parents(".lift").find(".toggle").toggleClass("active");
	            })
	            
	            
	        },error : function (e){
	            layer.msg("请求错误！请稍候重试",{icon:2,time:3000});
	        }
	    });	
        
        $(".book").on("click",function(){

    		
    		var roomNum = 0;
    		var peopleNum = 0 ;
    		for (i = 0 ; i < $("#roomCont .lift").length ; i++) {
    			if ($("#roomCont .lift").eq(i).attr("data-roomnum") != "请选择" && $("#roomCont .lift").eq(i).attr("data-roomnum") != 0 && $("#roomCont .lift").eq(i).attr("data-roomnum") != undefined) {
    				roomNum += Number($("#roomCont .lift").eq(i).attr("data-roomnum"));
    			}
    			if ($("#roomCont .lift").eq(i).attr("data-peoplenum") != "请选择" && $("#roomCont .lift").eq(i).attr("data-peoplenum") != 0 && $("#roomCont .lift").eq(i).attr("data-peoplenum") != undefined) {
    				peopleNum += Number($("#roomCont .lift").eq(i).attr("data-peoplenum"));
    			}
    			if ($("#roomCont .lift").eq(i).attr("data-childnum") != "请选择" && $("#roomCont .lift").eq(i).attr("data-childnum") != 0 && $("#roomCont .lift").eq(i).attr("data-childnum") != undefined) {
    				peopleNum += Number($("#roomCont .lift").eq(i).attr("data-childnum"));
    			}
    			if ($("#roomCont .lift").eq(i).attr("data-addbad") != "请选择" && $("#roomCont .lift").eq(i).attr("data-addbad") != 0 && $("#roomCont .lift").eq(i).attr("data-addbad") != undefined) {
    				peopleNum += Number($("#roomCont .lift").eq(i).attr("data-addbad"));
    			}
    			if ($("#roomCont .lift").eq(i).attr("data-difference") != "请选择" && $("#roomCont .lift").eq(i).attr("data-difference") != 0 && $("#roomCont .lift").eq(i).attr("data-difference") != undefined) {
    				peopleNum += Number($("#roomCont .lift").eq(i).attr("data-difference"));
    			}
    		}
	    	if( (roomNum*2) < peopleNum || (roomNum*2) == peopleNum){
	    		if ( (roomNum*4) > peopleNum || (roomNum*4) == peopleNum ) {
	    			var token = JSON.parse(localStorage.getItem('token'));
			        var json = {
			        	hotelName : $("#name").html(),
			        	startTime : $("#come1").val(),
			        	endTime : $("#level1").val(),
			        	orderPirce : calculate(),
			        	id : token.id,
			        	userId : token.id ,
			        	dayNum : $("#data").html(),
			        	hotelId : wang.getQueryString("id"),
			        	orderDetailEntities :[]
			        }
					var roomIdList = [],
						roomNum = 0;
			        for (i = 0 ; i < $("#roomCont .lift").length ; i++) {
			        	
			        	if ($("#roomCont .lift").eq(i).attr("data-roomnum") != "请选择" && $("#roomCont .lift").eq(i).attr("data-roomnum") != 0 && $("#roomCont .lift").eq(i).attr("data-roomnum") != undefined) {
					
							json.orderDetailEntities.push({
			        			roomId : $("#roomCont .lift").eq(i).attr("data-roomid"),
			        			roomNum: $("#roomCont .lift").eq(i).attr("data-roomnum"),
			        			roomName :  $("#roomCont .lift").eq(i).find(".list11").find(".fl").html(),
			        			ischildBad : $("#roomCont .lift").eq(i).attr("data-isbad") || 0,
			        			childNum : $("#roomCont .lift").eq(i).attr("data-childnum") || 0,
			        			addBedNum : $("#roomCont .lift").eq(i).attr("data-addbad") || 0,   
			        			difference : $("#roomCont .lift").eq(i).attr("data-difference") || 0 ,
			        			orderPeople : $("#roomCont .lift").eq(i).attr("data-peoplenum") || 0 ,
			        			roomMoney : $("#roomCont .lift").eq(i).attr("data-roommoney") || 0 ,
			        			childprice :  $("#roomCont .lift").eq(i).attr("data-childprice") || 0 ,
			        			isBigBad : $("#roomCont .lift").eq(i).attr("data-isbigbad") || 1 ,
			        			childbedprice :  $("#roomCont .lift").eq(i).attr("data-childbedprice") || 0 ,
			        			addbedprice :  $("#roomCont .lift").eq(i).attr("data-addbedprice") || 0 ,
			        			singleprice :  $("#roomCont .lift").eq(i).attr("data-singleprice") || 0 ,
			        			orderGuestEntities :[]
			        		})
							
			        	}
			        	
			        }
			    	
			    	$.ajax({
			    	    type:"post",
			    	    url:"http://52lvu.cn:8080/api/room/isHaveRoom",
			    	    data:{
			    	        json : JSON.stringify(json)
			    	    },success : function (result){
			    	        
			    	        if (result.resultCode == 200) {
			        		  	localStorage.orderJson = JSON.stringify(json);
								window.location.href = "order.html?id="+wang.getQueryString("id")+"&hotelId="+wang.getQueryString("hotelId")
			    	        } else{
			    	        	layer.msg(result.message,{icon:2,time:2000})
			    	        }
			    	        
			    	    },error : function (e){
			    	        layer.msg("请求错误,请稍后重试",{icon:2,time:2000})
			    	    }
			    	});
			    	
	    		}else{
	    			layer.open({
				    	type: 2,
				    	title: '预定须知',
				    	shadeClose: true,
				    	shade: false,
				    	maxmin: true,
				    	area: ['893px', '600px'],
				    	content: 'caption.html'
				  	})
	    		}
	    	}else{
		    	    layer.open({
				    	type: 2,
				    	title: '预定须知',
				    	shadeClose: true,
				    	shade: false,
				    	maxmin: true,
				    	area: ['893px', '600px'],
				    	content: 'caption.html'
				  	})
		    	    
	    		
	    	}
	    	
	    })
        
        
        
        function calculate(){
            var money= 0 ;
            var days = Number($("#data").html());
            for (i = 0 ; i < $(".lift").length ; i++) {
            	// 成人
        		var cr = toNumber($(".lift").eq(i).attr("data-roommoney"))*toNumber($(".lift").eq(i).attr("data-peoplenum"));
            	//儿童
            	if($(".lift").eq(i).attr("data-isbad") == 1){
				var et = money += toNumber($(".lift").eq(i).attr("data-childbedprice"))*toNumber($(".lift").eq(i).attr("data-childnum"))
            	}else{
            	var et = toNumber($(".lift").eq(i).attr("data-childprice"))*toNumber($(".lift").eq(i).attr("data-childnum"))
            	}
            	// 加床
        		var jc = toNumber($(".lift").eq(i).attr("data-addbedprice"))*toNumber($(".lift").eq(i).attr("data-addbad"))
        		//	单房差
        		var dfc = toNumber($(".lift").eq(i).attr("data-singleprice"))*toNumber($(".lift").eq(i).attr("data-difference"))
    
           		money += cr + et + jc + dfc ;
            }
            $("#price1").html("￥"+money*days);
            return money*days;
        }
        
        function toNumber(num){
            if (num) {
            	return Number(num);
            }else{
            	return 0
            }
        }
        
        
		var btnTop = $(".moneylist ul").offset().top;
        
        $(window).scroll(function(event){
			if ( $(window).scrollTop() > btnTop) {
				$(".moneylist ul").addClass("offset")
			}
			if ( $(window).scrollTop() < btnTop) {
				$(".moneylist ul").removeClass("offset")
			}
    	});
        
        
    });


    

</script>
<script src="js/calendar.js" type="text/javascript" charset="utf-8"></script>